package adapter;

import java.util.ArrayList;

import com.activity.MainAppActivity;
import com.activity.R;

import entities.MyLocate;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AdapterMyLocate extends ArrayAdapter<MyLocate>{
	private Context context;
	private ArrayList<MyLocate> myLocates;
	private int resid;
	public AdapterMyLocate(Context context, int resource,ArrayList<MyLocate> list) {
		super(context, resource, list);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.resid=resource;
		this.myLocates=list;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(resid, null);
		}
		TextView txtName=(TextView) convertView.findViewById(R.id.txt_ml_name);
		txtName.setTypeface(MainAppActivity.typeFaceFont);
		TextView txtAddress=(TextView) convertView.findViewById(R.id.txt_ml_address);
		txtAddress.setTypeface(MainAppActivity.typeFaceFont);
		MyLocate myLocate=myLocates.get(position);
		txtAddress.setText(myLocate.getAddress());
		txtName.setText(myLocate.getName());
		return convertView;
	}
	
}
